<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="reg.css">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <link rel="stylesheet" href="forget.css">
    <style>
        #newpwd2{
            padding: 7px;
        }
        #newpwd1{
            padding: 7px;
        }
        .c{
            color: #afafaf;
            font-size: 14px;
        }
    </style>
</head>
<body style="background-color: #f3f3f3">
<div id="zong">
    <div class="biaoti">设置你的新密码</div>
    <div class="yanzheng">
        <div class="tishi">
            <ul>
                <li>请输入你的新密码</li>
            </ul>
        </div>
        <div class="input">
            <div>新密码</div>
            <div><input id="newpwd1" placeholder="请输入密码" type="password"/></div>
            <div class="error error2" id="error2"></div>
            <div class="c">确认密码</div>
            <div><input id="newpwd2" placeholder="请确认密码" type="password"/></div>
            <div class="error error3" id="error3"></div>
            <div id="resetbtn3">重置密码</div>
            <div style="text-align: center;font-size:14px" id="tip"></div>
        </div>
    </div>
</div>
</body>
<script src="jquery-3.4.1.js"></script>
<script src="gong.js"></script>
<script>
    resetbtn3.onclick = function(){
        var pwdValue=newpwd1.value;
        var pwdValue2=newpwd2.value;
        if(pwdValue.length==0){
            error2.innerHTML="此项必须填写";
            error2.className="error";
            pwdRight=false;
            newpwd1.className="";
            return;
        }else if(pwdValue.length<6){
            error2.innerHTML="密码至少6位，支持数字、字母和符号";
            error2.className="error";
            pwdRight=false;
            newpwd1.className="";
            return;
        }else if(pwdValue.length<8){
            error2.innerHTML="强度高的密码至少需要8个字符，同时包含大小写字母、数字和符号。";
            error2.className="warn";
            pwdRight=true;
            newpwd1.className="warnbg";
            return;
        }else{
            error2.innerHTML="";
            error2.className="error";
            newpwd1.className="";
            pwdRight=true;
        }

        if(pwdValue2.length==0){
            error3.innerHTML="此项必须填写";
            error3.className="error";
            pwdRight=false;
            return;
            newpwd2.className="";
        }else if(pwdValue.length<6){
            error3.innerHTML="密码至少6位，支持数字、字母和符号";
            error3.className="error";
            pwdRight=false;
            return;
            newpwd2.className="";
        }else if(pwdValue.length<8){
            error3.innerHTML="强度高的密码至少需要8个字符，同时包含大小写字母、数字和符号。";
            error3.className="warn";
            pwdRight=true;
            newpwd2.className="warnbg";
            return;
        }else{
            error3.innerHTML="";
            error3.className="error";
            newpwd2.className="";
            pwdRight=true;
        }
        if(pwdValue!=pwdValue2){
            tip.innerHTML="两次输入密码不一致！";
            return;
        }
        ajax("/bijiuser/resetpwd",{tel:localStorage.forgetTel,pwd:newpwd1.value},
            function(data){
                if(data=="修改成功"){
                    location = "forget4.html";
                }else{
                    tip.innerHTML = data;
                }
            });

    };

    newpwd1.onfocus=function () {
        error2.innerHTML="";
    };
    newpwd2.onfocus=function () {
        error2.innerHTML="";
    };
</script>
</html>